import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const commonRoutes = [
    {
        path: '/login',
        name: 'login',
        component: () => import('../components/Login.vue')
    },
    { path: '/', redirect: '/home' },
]

// 需要通过后台数据来生成的组件
export const asyncRoutes = {
    'home': {
        path: 'home',
        name: 'home',
        component: () => import('../views/home/Home.vue')
    },
    'tabel': {
        path: 'tabel',
        name: 'tabel',
        component: () => import('../views/tabel/Table.vue')
    },
    'echarts': {
        path: 'echarts',
        name: 'echarts',
        component: () => import('../views/echarts/Echarts.vue')
    },
    'barEcharts': {
        path: 'barEcharts',
        name: 'barEcharts',
        component: () => import('../views/barEcharts/barEcharts.vue')
    },
	'dashBoard': {
        path: 'dashBoard',
        name: 'dashBoard',
        component: () => import('../views/dashBoard/dashBoard.vue')
    },
}

const createRouter = () => new Router({
    routes: commonRoutes
})

const router = createRouter()

export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher
}

export default router